//
//
//
//


#include "common.h"
#include "WorkThread.h"
#include "ThreadManager.h"


#undef CLASSCATEGORY
#define CLASSCATEGORY "WorkThread"

WorkThread::WorkThread(ThreadManager* pMan)
{
	_idleSecs = 0;
	_busySecs = 0;

	// Ignor error no
	int nRet = pthread_create(&_threadID,
			NULL,
			pMan->ThreadEntry,
			this);
}

WorkThread::~WorkThread()
{};


void WorkThread::SetJob(BaseJob* pJob)
{
	_job = pJob;
}

void WorkThread::Start()
{
	if(NULL == _job)
		return;
	_job->Run();
	_job = NULL;
}

void WorkThread::Report(std::ostream& os)
{
	os << CLASSCATEGORY
		<< ":" 
		<< _threadID
		<< ":" << _idleSecs
		<< ":" << _busySecs;
}
